﻿using System;
using System.Collections;
using mojoPortal.Web.Framework;

namespace ud_Menu
{
    /// <summary>
    /// encapsulates the feature instance configuration loaded from module settings into a more friendly object
    /// </summary>
    public class MenuConfiguration
    {
        public MenuConfiguration()
        { }

        public MenuConfiguration(Hashtable settings)
        {
            LoadSettings(settings);
        }

        private void LoadSettings(Hashtable settings)
        {
            if (settings == null) { throw new ArgumentException("must pass in a hashtable of settings"); }

            if (settings.Contains("CustomCssClassSetting"))
            {
                customCssClass = settings["CustomCssClassSetting"].ToString();
            }

            if (settings.Contains("HeaderTextSetting"))
            {
                headerText = settings["HeaderTextSetting"].ToString();
            }

            if (settings.Contains("FooterTextSetting"))
            {
                footerText = settings["FooterTextSetting"].ToString();
            }

            if (settings.Contains("DirectionSetting"))
            {
                direction = settings["DirectionSetting"].ToString();
            }

            enableUnclickableLinks = WebUtils.ParseBoolFromHashtable(settings, "EnableUnclickableLinksSetting", enableUnclickableLinks);
            useTreeView = WebUtils.ParseBoolFromHashtable(settings, "UseTreeViewSetting", useTreeView);
            useSuperfish = WebUtils.ParseBoolFromHashtable(settings, "UseSuperfishSetting", useSuperfish);
            useArtisteer = WebUtils.ParseBoolFromHashtable(settings, "UseArtisteerSetting", useArtisteer);
            useLavaLamp = WebUtils.ParseBoolFromHashtable(settings, "UseLavaLampSetting", useLavaLamp);
            suppressPageSelection = WebUtils.ParseBoolFromHashtable(settings, "SuppressPageSelectionSetting", suppressPageSelection);
            treeViewPopulateOnDemand = WebUtils.ParseBoolFromHashtable(settings, "TreeViewPopulateOnDemandSetting", treeViewPopulateOnDemand);
            treeViewExpandDepth = WebUtils.ParseInt32FromHashtable(settings, "TreeViewExpandDepthSetting", treeViewExpandDepth);
            treeViewShowExpandCollapse = WebUtils.ParseBoolFromHashtable(settings, "TreeViewShowExpandCollapseSetting", treeViewShowExpandCollapse);
            treeviewPopulateNodesFromClient = WebUtils.ParseBoolFromHashtable(settings, "TreeviewPopulateNodesFromClientSetting", treeviewPopulateNodesFromClient);
            startingNodeOffset = WebUtils.ParseInt32FromHashtable(settings, "StartingNodeOffsetSetting", startingNodeOffset);
            dynamicDisplayLevels = WebUtils.ParseInt32FromHashtable(settings, "DynamicDisplayLevelsSetting", dynamicDisplayLevels);
            topLevelOnly = WebUtils.ParseBoolFromHashtable(settings, "TopLevelOnlySetting", topLevelOnly);
            includeCornerRounders = WebUtils.ParseBoolFromHashtable(settings, "IncludeCornerRoundersSetting", includeCornerRounders);
            useSpanInLinks = WebUtils.ParseBoolFromHashtable(settings, "UseSpanInLinksSetting", useSpanInLinks);
            use3SpansInLinks = WebUtils.ParseBoolFromHashtable(settings, "Use3SpansInLinksSetting", use3SpansInLinks);
            hideMenuOnSiteMap = WebUtils.ParseBoolFromHashtable(settings, "HideMenuOnSiteMapSetting", hideMenuOnSiteMap);
        }

        private string customCssClass = string.Empty;
        public string CustomCssClass { get { return customCssClass; } }      
        
        private bool enableUnclickableLinks = true;
        public bool EnableUnclickableLinks { get { return enableUnclickableLinks; } }

        private bool useTreeView;
        public bool UseTreeView { get { return useTreeView; } }

        private bool useSuperfish;
        public bool UseSuperfish { get { return useSuperfish; } }

        private bool useArtisteer;
        public bool UseArtisteer { get { return useArtisteer; } }

        private bool useLavaLamp;
        public bool UseLavaLamp { get { return useLavaLamp; } }

        private bool suppressPageSelection;
        public bool SuppressPageSelection { get { return suppressPageSelection; } }

        private bool treeViewPopulateOnDemand = true;
        public bool TreeViewPopulateOnDemand { get { return treeViewPopulateOnDemand; } }

        private int treeViewExpandDepth;
        public int TreeViewExpandDepth { get { return treeViewExpandDepth; } }
        
        private bool treeViewShowExpandCollapse = true;
        public bool TreeViewShowExpandCollapse { get { return treeViewShowExpandCollapse; } }

        private bool treeviewPopulateNodesFromClient = true;
        public bool TreeviewPopulateNodesFromClient { get { return treeviewPopulateNodesFromClient; } }

        private int startingNodeOffset;
        public int StartingNodeOffset { get { return startingNodeOffset; } }

        private int dynamicDisplayLevels = 100;
        public int DynamicDisplayLevels { get { return dynamicDisplayLevels; } }

        private bool topLevelOnly;
        public bool TopLevelOnly { get { return topLevelOnly; } }

        private string direction = "Horizontal";
        public string Direction { get { return direction; } }

        private bool includeCornerRounders = true;
        public bool IncludeCornerRounders { get { return includeCornerRounders; } }

        private bool useSpanInLinks;
        public bool UseSpanInLinks { get { return useSpanInLinks; } }

        private bool use3SpansInLinks = true;
        public bool Use3SpansInLinks { get { return use3SpansInLinks; } }

        private bool hideMenuOnSiteMap = true;
        public bool HideMenuOnSiteMap { get { return hideMenuOnSiteMap; } }

        private string headerText = string.Empty;
        public string HeaderText { get { return headerText; } }

        private string footerText = string.Empty;
        public string FooterText { get { return footerText; } }
    }
}